<?php

namespace app\modules\admin\controllers;

use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;

/**
 * Default controller for the `admin` module
 */
class BaseController extends Controller
{
    public $layout = 'main';

    public function beforeAction($action)
    {
        if(Yii::$app->request->getPathInfo() != 'admin/site/login' && Yii::$app->user->isGuest) {
            $this->redirect('/admin/site/login');
            return false;
        }

//        //基于rabc的权限管理
//        $action = Yii::$app->controller->action->id;
//        if(!Yii::$app->user->can($action)){
//            Yii::$app->session->addFlash('error');
//
//            return $this->render('/site/error_403');
//        }

        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }
}
